package org.sgx.dao.test.test1.testModel;

import java.util.Date;

import org.sgx.dao.model.Model;
import org.sgx.dao.util.BeanUtil;
import org.sgx.dao.util.Util;


/**A sample java class which instances will be stored to database using the framework.
 * the model class is a simple bean which fields are of simple type. 
 * it must implement Model for telling what field will be used for id.
 */
public class BeanTest1 implements Model{
	String strField1;
	Long longField1;
	Boolean boolField1;
	Date dateField1;
	Long longField2;
	public BeanTest1(String strField1, Long longField1, Boolean boolField1,
			Date dateField1) {
		this(strField1, longField1, 0, boolField1, dateField1);
		
	}
	/** default constructor required */
	public BeanTest1(){}
	public BeanTest1(String strField1, long longField1, long longField2,
			boolean boolField1, Date dateField1) {
		this.strField1 = strField1;
		this.longField1 = longField1;
		this.longField2 = longField2;
		this.boolField1 = boolField1;
		this.dateField1 = dateField1;
	}
	public String getStrField1() {
		return strField1;
	}
	public void setStrField1(String strField1) {
		this.strField1 = strField1;
	}
	public Long getLongField1() {
		return longField1;
	}
	public void setLongField1(Long longField1) {
		this.longField1 = longField1;
	}
	public Boolean getBoolField1() {
		return boolField1;
	}
	public void setBoolField1(Boolean boolField1) {
		this.boolField1 = boolField1;
	}
	public Date getDateField1() {
		return dateField1;
	}
	public void setDateField1(Date dateField1) {
		this.dateField1 = dateField1;
	}
	public String getFieldIdName() {
		return "longField1";
	}
	
	@Override
	public String toString() {
		return BeanUtil.dumpBean(this);
	}
	@Override
	public boolean equals(Object obj) {
		if(obj instanceof BeanTest1) {
			BeanTest1 b2 = (BeanTest1)obj;
			return b2.boolField1.equals(boolField1)&&
				b2.strField1.equals(strField1) && b2.longField1.equals(longField1) && 
				Util.dateEquals(b2.dateField1, dateField1);
		}
		else
			return false;
	}
	public Long getLongField2() {
		return longField2;
	}
	public void setLongField2(Long longField2) {
		this.longField2 = longField2;
	}
	
}